<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>添加商品类别</h2>

<input placeholder="请输入类别名称" id="txtType">

<button type="button" id="btnSaveType">保存</button>
</body>

<script src="js/jquery-3.2.1.js"></script>
<script src="js/layer/layer.js"></script>
<script>
    $(function () {
        $('#btnSaveType').click(function () {
            $.ajax({
                url: 'add_type.do',
                data: {tname: $('#txtType').val()},
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    //console.log(data);
                    if (data.code == 200) {
                        layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                            location.href = "category_list.html";
                        })
                    }
                },
                error: function () {

                }
            })
        })
    })

</script>

</html>